home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Translation.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  12.0 KB  |  309 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Translation.h
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __TRANSLATION__
  21. #define __TRANSLATION__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __FILES__
  30. #include <Files.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <OSUtils.h>                                        */
  34. /*        #include <Memory.h>                                        */
  35.  
  36. #ifndef __COMPONENTS__
  37. #include <Components.h>
  38. #endif
  39.  
  40. #ifndef __TRANSLATIONEXTENSIONS__
  41. #include <TranslationExtensions.h>
  42. #endif
  43. /*    #include <Quickdraw.h>                                        */
  44. /*        #include <QuickdrawText.h>                                */
  45.  
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49.  
  50. #if PRAGMA_ALIGN_SUPPORTED
  51. #pragma options align=mac68k
  52. #endif
  53.  
  54. #if PRAGMA_IMPORT_SUPPORTED
  55. #pragma import on
  56. #endif
  57.  
  58. typedef short DocOpenMethod;
  59.  
  60.  
  61. enum {
  62.     domCannot,
  63.     domNative,
  64.     domTranslateFirst,
  65.     domWildcard
  66. };
  67.  
  68. /* 0L terminated array of OSTypes, or FileTypes*/
  69. typedef OSType TypesBlock[64];
  70.  
  71. typedef OSType *TypesBlockPtr;
  72.  
  73. /* Progress dialog resource ID*/
  74.  
  75. enum {
  76.     kTranslationScrapProgressDialogID = -16555
  77. };
  78.  
  79. /* block of data that describes how to translate*/
  80. struct FileTranslationSpec {
  81.     OSType                            componentSignature;
  82.     const void                        *translationSystemInfo;
  83.     FileTypeSpec                    src;
  84.     FileTypeSpec                    dst;
  85. };
  86. typedef struct FileTranslationSpec FileTranslationSpec;
  87.  
  88. typedef FileTranslationSpec *FileTranslationSpecArrayPtr;
  89.  
  90. /*****************************************************************************************
  91. *   GetFileTypesThatAppCanNativelyOpen
  92. *  This routine returns a list of all FileTypes that an application can open by itself
  93. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  94. *             appSignature        signature (creator) of application
  95. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  96. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  97. */
  98. extern pascal OSErr GetFileTypesThatAppCanNativelyOpen(short appVRefNumHint, OSType appSignature, FileType *nativeTypes)
  99.  TWOWORDINLINE(0x701C, 0xABFC);
  100. /*****************************************************************************************
  101. *  ExtendFileTypeList
  102. *  This routine makes a new list of file types that can be translated into a type in the given list
  103. *  Used by StandardFile
  104. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  105. *             numberOriginalTypes        number of file types in orgTypeList
  106. *              extendedTypeList        pointer to a buffer to be filled with file types
  107. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  108. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  109. *             numberExtendedTypes        number of file types put in extendedTypeList
  110. */
  111. extern pascal OSErr ExtendFileTypeList(const FileType *originalTypeList, short numberOriginalTypes, FileType *extendedTypeList, short *numberExtendedTypes)
  112.  TWOWORDINLINE(0x7009, 0xABFC);
  113. /*****************************************************************************************
  114. *  This routine checks if a file can be opened by a particular application.
  115. *  If so, it returns if it needs to be translated first, and if so then how.
  116. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  117. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  118. *  Enter:    targetDocument        document to check if it can be opened
  119. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  120. *             appSignature        signature (creator) of application to open doc
  121. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  122. *             onlyNative            whether to consider if document can be translated before opening
  123. *             howToOpen            pointer to buffer in which to put how the document can be opened
  124. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  125. *  Exit:    howToOpen            whether file needs to be translated to be read
  126. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  127. *             returns                noErr, noPrefAppErr
  128. */
  129. extern pascal OSErr CanDocBeOpened(const FSSpec *targetDocument, short appVRefNumHint, OSType appSignature, const FileType *nativeTypes, Boolean onlyNative, DocOpenMethod *howToOpen, FileTranslationSpec *howToTranslate)
  130.  TWOWORDINLINE(0x701E, 0xABFC);
  131. /*****************************************************************************************
  132. *  GetFileTranslationPaths
  133. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  134. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  135. *  Enter:    srcDoc            source file or NULL for all matches
  136. *             dstDoc            destination FileType or NULL for all matches
  137. *             maxResultCount
  138. *             resultBuffer
  139. *  Exit:    number of paths
  140. */
  141. extern pascal short GetFileTranslationPaths(FSSpec *srcDocument, FileType dstDocType, unsigned short maxResultCount, FileTranslationSpecArrayPtr resultBuffer)
  142.  TWOWORDINLINE(0x7038, 0xABFC);
  143. /*****************************************************************************************
  144. *  GetPathFromTranslationDialog
  145. *  This routine, with a given document, application, and a passed typelist will display the
  146. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  147. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  148. *  The routine returns the translation path information.
  149. *  Enter:    theDocument            FSSpec to document to open
  150. *             theApplication        FSSpec to application to open document
  151. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  152. *                                 you would like the documented translated to.  Order most perferred
  153. *                                 to least.
  154. *  Exit:    howToOpen            Translation method needed to open document
  155. *             howToTranslate        Translation specification
  156. *             returns                Any errors that might occur.
  157. */
  158. extern pascal OSErr GetPathFromTranslationDialog(const FSSpec *theDocument, const FSSpec *theApplication, TypesBlockPtr typeList, DocOpenMethod *howToOpen, FileTranslationSpec *howToTranslate)
  159.  TWOWORDINLINE(0x7037, 0xABFC);
  160. /*****************************************************************************************
  161. *   TranslateFile
  162. *  This routine reads a file of one format and writes it to another file in another format. 
  163. *  The information on how to translated is generated by the routine CanDocBeOpened.
  164. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  165. *  The destination file must not exist.  It is created by this routine.  
  166. *  Enter:    sourceDocument            input file to translate
  167. *             destinationDocument        output file of translation
  168. *             howToTranslate            pointer to info on how to translate
  169. *  Exit:    returns                    noErr, badTranslationSpecErr 
  170. */
  171. extern pascal OSErr TranslateFile(const FSSpec *sourceDocument, const FSSpec *destinationDocument, const FileTranslationSpec *howToTranslate)
  172.  TWOWORDINLINE(0x700C, 0xABFC);
  173. /*****************************************************************************************
  174. *   GetDocumentKindString
  175. *  This routine returns the string the Finder should show for the "kind" of a document
  176. *  in the GetInfo window and in the kind column of a list view.  
  177. *  Enter:    docVRefNum        The volume containing the document
  178. *             docType            The catInfo.fdType of the document
  179. *             docCreator        The catInfo.fdCreator of the document
  180. *             kindString        pointer to where to return the string
  181. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  182. *             returns            noErr, or afpItemNoFound if kind could not be determined
  183. */
  184. extern pascal OSErr GetDocumentKindString(short docVRefNum, OSType docType, OSType docCreator, Str63 kindString)
  185.  TWOWORDINLINE(0x7016, 0xABFC);
  186. /*****************************************************************************************
  187. *  GetTranslationExtensionName
  188. *  This routine returns the translation system name from a specified TranslationSpec
  189. *  Enter:    translationMethod    The translation path to get the translation name from
  190. *  Exit:    extensionName        The name of the translation system
  191. *             returns                Any errors that might occur
  192. */
  193. extern pascal OSErr GetTranslationExtensionName(const FileTranslationSpec *translationMethod, Str31 extensionName)
  194.  TWOWORDINLINE(0x7036, 0xABFC);
  195. /*****************************************************************************************
  196. *  GetScrapDataProcPtr
  197. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  198. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  199. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  200. *  with a list all the formats that you have available to be translated, and the length of each.
  201. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  202. *  the formats that 'fmts' list said was available.
  203. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  204. *             dataH                    Handle in which to put the requested data
  205. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  206. *             
  207. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  208. */
  209. typedef pascal OSErr (*GetScrapDataProcPtr)(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  210.  
  211. #if GENERATINGCFM
  212. typedef UniversalProcPtr GetScrapDataUPP;
  213. #else
  214. typedef GetScrapDataProcPtr GetScrapDataUPP;
  215. #endif
  216.  
  217. enum {
  218.     uppGetScrapDataProcInfo = kPascalStackBased
  219.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  220.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ScrapType)))
  221.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
  222.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void*)))
  223. };
  224.  
  225. #if GENERATINGCFM
  226. #define NewGetScrapDataProc(userRoutine)        \
  227.         (GetScrapDataUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  228. #else
  229. #define NewGetScrapDataProc(userRoutine)        \
  230.         ((GetScrapDataUPP) (userRoutine))
  231. #endif
  232.  
  233. #if GENERATINGCFM
  234. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)        \
  235.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  236. #else
  237. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)        \
  238.         (*(userRoutine))((requestedFormat), (dataH), (srcDataGetterRefCon))
  239. #endif
  240.  
  241. typedef GetScrapDataUPP GetScrapData;
  242.  
  243. /*****************************************************************************************
  244. *  TranslateScrap
  245. *  This routine resizes the destination handle and fills it with data of the requested format.
  246. *  The data is generated by translated one or more source formats of data supplied by
  247. *  the procedure srcDataGetter.  
  248. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  249. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  250. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  251. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  252. *             destinationFormat            Format of data desired
  253. *             destinationData                Handle in which to store translated data
  254. *             
  255. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  256. */
  257. extern pascal OSErr TranslateScrap(GetScrapData sourceDataGetter, void *sourceDataGetterRefCon, ScrapType destinationFormat, Handle destinationData, short progressDialogID)
  258.  TWOWORDINLINE(0x700E, 0xABFC);
  259.  
  260. #if PRAGMA_IMPORT_SUPPORTED
  261. #pragma import off
  262. #endif
  263.  
  264. #if PRAGMA_ALIGN_SUPPORTED
  265. #pragma options align=reset
  266. #endif
  267.  
  268. #ifdef __cplusplus
  269. }
  270. #endif
  271.  
  272. #endif /* __TRANSLATION__ */
  273.